function noUp(e){
	if(window.event){
		event.cancelBubble = true;
	}else{
		e.stopPropagation();
	}
}

document.onkeydown=function(event){
	e = event ? event :(window.event ? window.event : null); 
	var obj = e.target || e.srcElement; //获取事件源    
	var objType = obj.type || obj.getAttribute('type'); //获取事件源类型   
    var objReadOnly = obj.readOnly;    //获取作为判断条件的事件类型 
    objReadOnly = (objReadOnly == undefined) ? false : objReadOnly;  //处理undefined值情况     
	if ((e.altKey)&&
			((e.keyCode==37)||   //屏蔽 Alt+ 方向键 ←
			(e.keyCode==39)))   //屏蔽 Alt+ 方向键 →
	{
		e.returnValue=false;
	}
	//如果退格对象不是text 或者 是 readyOnly的text 则禁用退格
	if (e.keyCode==8 && objType != 'text' && objType != 'textarea' || (objType == 'text' && objReadOnly == true)){
		e.keyCode=0;
		e.returnValue=false;
	}
}

//打印
function myprint(s){
	if(s!=-1){
		var divList=document.getElementsByTagName("div");
		for(var m=0;m<divList.length;m++){
			if(divList[m].id.indexOf("type_") < 0) continue;
			if (s==0){
				divList[m].style.display= "";
			}else if (s==1){//打印客观题
				if ((divList[m].id=="type_1")||(divList[m].id=="type_2")||(divList[m].id=="type_3")){
					divList[m].style.display= "";
				}else if ((divList[m].id=="type_4")||(divList[m].id=="type_5")){
					divList[m].style.display= "none";
				}
			}else{//打印主观题　
				if ((divList[m].id=="type_1")||(divList[m].id=="type_2")||(divList[m].id=="type_3")){
					divList[m].style.display= "none";
				}else if ((divList[m].id=="type_4")||(divList[m].id=="type_5")){
					divList[m].style.display= "";
				}
			}
		}
	}
	window.print();
}

function fontzoon(myCssTable,size){
	$("#"+myCssTable).css("fontSize",size+"px");
}

function isExistSession(serialNum,siteCourseID,paperType,currConText){
	var paperViewID=$("#paperViewID").val();
	var chapterID=$("#chapterID").val();
	window.location=currConText+"/moniExam/common/getQues4Re.shtm?serialNum="+serialNum+"&siteCourseID="+siteCourseID+"&paperType="+paperType+"&paperViewID="+paperViewID+"&chapterID="+chapterID;
}

//主观题赋值
function sendFCK(){
	var allSerialNum=$("#allSerialNum").val();
	var sers= allSerialNum.split(",");
	for(var i=0;i<sers.length-1;i++){
		var seriNum = sers[i+1];
		var quesType=$("#quesTypeID_"+seriNum).val();
		if(quesType=="4"||quesType=="5"){
			var chinldIDs=$("#childQuestionIDs_"+seriNum).val();
			var quesTypeID=parseInt(quesType);
			sendValue4List(quesTypeID,chinldIDs);
		}
	}
	return true;
}

//多选题赋值
function sendMutipleSelect(serialNum){
	checkPaper(serialNum);
}

//写答案到cookie里
function autoSaveAnswer(paperViewID,userID){
	var iptList=document.getElementsByTagName("input");
	var stranswer="";//做题结果字符串
	for(var i=0;i<iptList.length;i++){
		var tmpAnswer="";
		//判断单选题或判断题的做题信息
		if(iptList[i].type == "radio" && iptList[i].checked){
			stranswer += iptList[i].name+"-"+iptList[i].value+",";
			continue;
		}
		//判断多选题做题信息
		if(iptList[i].title.indexOf("mutipleSelect")>-1){
			if(iptList[i].value!=""){
				stranswer += iptList[i].name+"-"+iptList[i].value+",";
				stranswer += tmpAnswer;
			}
			continue;
		}
	}
	setCookie("qz_"+paperViewID+"_"+userID,stranswer);
}

//从cookie里恢复答案
function setQuestionValueByCookie(paperViewID,userID){
	var iptList=document.getElementsByTagName("input");
	var cookQues = getCookie("qz_"+paperViewID+"_"+userID);
	if (cookQues != null){
		var arr = cookQues.split(",");
		for (var j=0;j<arr.length;j++){
			var item=arr[j].split("-")[0];
			var itemvalue=arr[j].split("-")[1];
			if(item!=""){
				var obj = $("#"+item+"_"+itemvalue);
				if (obj.length>0){
					obj.attr("checked",true);
				}
				obj = $("#"+item);
				if (obj.length>0){
					if(obj.attr("title").indexOf("mutipleSelect")>-1){
						obj.val(itemvalue);
						for(var i=0;i<itemvalue.length;i++){
							var value=itemvalue.substr(i,1);
							var obj = $("#checkbox_"+item+"_"+value);
							if (obj.length>0){
								obj.attr("checked",true);
							}
						}
					}
				}
			}
		}
	}
}

//自动调用，根据父窗口的大小调整自身大小
function reinitIframe(){
	var piframe = parent.document.getElementById("iframeSrc");	
	try{
		var bHeight = piframe.contentWindow.document.body.scrollHeight;	
		var dHeight = piframe.contentWindow.document.documentElement.scrollHeight;	
		var height = Math.max(bHeight, dHeight);
		$("#iframeSrc",parent.document.body).css("height",height);
	}catch (ex){}
}

//判断用户是否已经答题
function isExistUserAnser(currConText){
	var htmlobj=$.ajax({
		type: 'POST',
		async: false,
		url: currConText+"/moniExam/isExistAnswer.shtm"
	});
	var result=$.trim(htmlobj.responseText);
	if(result=="-1"){
		$("#bgg").show();
		$("#showDiv1").css("display","none");
		$("#showDiv2").css("display","block");
		setTimeout("$('#bgg').hide(0);clearLockScreen();",2000);
		return false;
	}else{
		return true;
	}
}

//用户答题时间未超过15秒，禁止用户提交
function isSubmite(spendSecond){
	var contestParanTime=$("#vConTestPaperTime").val();
	if(spendSecond+15*60<=contestParanTime*60 || spendSecond<=0 || contestParanTime<=15){
		return true;
	}else{
		$("#bgg").show();
		$("#showDiv1").css("display","none");
		$("#showDiv2").css("display","block");
		$("#errorMsg").text("您的作答时间不足15分钟,请认真作答！");
		setTimeout("$('#bgg').hide(0);clearLockScreen();",2000);
		return false;
	}
}